package me.leiusual.sharing.ui.home.adapter

import android.content.Context
import android.view.View
import android.widget.ImageView
import androidx.recyclerview.widget.RecyclerView
import com.youth.banner.loader.ImageLoader
import kotlinx.android.extensions.LayoutContainer
import kotlinx.android.synthetic.main.view_holder_home_banner.*
import me.leiusual.sharing.util.extension.setImageUrl

/**
 * Create by leiusual on 2018/7/24
 */
class HomeBannerViewHolder(
    override val containerView: View
) : RecyclerView.ViewHolder(containerView), LayoutContainer {

  private val imageLoader = object : ImageLoader() {
    override fun displayImage(context: Context?, path: Any?, imageView: ImageView?) {
      imageView?.setImageUrl(path)
    }
  }

  fun bind(data: HomeHomeAdapter.Item) {
    val list = data.dataSet.map { it.image }
    banner.setImages(list).setImageLoader(imageLoader).start()
  }
}